﻿@using Abp.Application.Services.Dto;
@using FwProject.Restaurant
@using FwProject.Restaurant.Dto

@model DepositDto
@{
    ViewBag.Title = "收押金[" + Model.CreationNumber + "]";
}
@section styles{
<link href="~/Theme/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="~/Theme/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<style type="text/css">
    .input-group[class*=col-] {
        padding: 0 15px;
    }

    .checked {
        position: absolute;
        top: 3px;
        left: 220px;
        height: 87px;
        width: 141px;
        background: url('/images/checked.gif') left top no-repeat;
        z-index: 9999;
    }
</style>
}
<div class="row wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>@ViewBag.Title</h5>
                <div class="ibox-tools">
                    @if (Model.DepositStatus == DepositStatus.未提交 || Model.DepositStatus == DepositStatus.退回)
                    {
                    <a class="btn btn-primary btn btn-xs" data-toggle="modal" data-target="#modal_ajax" data-backdrop="static" data-url="/Deposit/Edit?id=@Model.Id">修改</a>
                    <a href="/Deposit/EditStatus?id=@Model.Id" class="btn btn-primary btn btn-xs">提交</a>
                    @*<button class="btn btn-primary btn btn-xs" id="btnSubmit">提交</button>*@
                    }

                    @if (Model.DepositStatus == DepositStatus.已提交)
                    {
                    @*<a class="btn btn-primary btn btn-xs" data-toggle="modal" data-target="#modal_ajax" data-backdrop="static" data-url="/Deposit/Edit?id=@Model.Id">修改</a>*@
                    <a href="/Deposit/EditExamineStatus?id=@Model.Id" class="btn btn-primary btn btn-xs">审核</a>
                    }

                    @if (Model.DepositStatus == DepositStatus.已审核)
                    {
                    <a href="/Deposit/EditBackStatus?id=@Model.Id" class="btn btn-primary btn btn-xs">反审核</a>
                    }

                    @if (Model.DepositStatus == DepositStatus.已提交 || Model.DepositStatus == DepositStatus.已审核)
                    {
                    <a onclick="window.open('/Deposit/CollectDepositPrint?id=@Model.Id')" class="btn btn-primary btn btn-xs">打印</a>
                    }

                </div>
            </div>
            <div class="ibox-content" style="height:700px">
                <div class="row m-b-sm m-t-sm">
                    <form class="form-horizontal" asp-controller="Deposit" asp-action="Edit" data-ajax="true" data-ajax-update="#data_list" data-ajax-method="Get" data-ajax-mode="replace">
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">单号：</label>
                                <div class="input-group">
                                    <input type="text" name="CreationNumber" class="input-sm form-control" value="@Model.CreationNumber" readonly="readonly">
                                </div>
                                @if (Model.DepositStatus == DepositStatus.已审核)
                                {
                                <div class="checked" id="check_icon"></div>
                                }
                            </div>
                            <div class="col-md-6">
                                <label class="control-label col-md-3">日期：</label>
                                <div class="input-group">
                                    <input type="text" name="DepositTime" class="input-sm form-control" value="@Model.DepositTime.ToString(" yyyy-MM-dd")" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">餐厅：</label>
                                <div class="input-group">
                                    <input type="text" name="RestaurantName" class="input-sm form-control" value="@Model.RestaurantInfoModel.RestaurantName" readonly="readonly">
                                </div>
                            </div>
                            <div class="col-md-6">
                                @if (Model.DepositType == DepositType.收押金)
                                {
                                <label class="control-label col-md-3">押金金额：</label>
                                }
                                else
                                {
                                <label class="control-label col-md-3">退回金额：</label>
                                }
                                <div class="input-group">
                                    <input type="text" name="Money" class="input-sm form-control" value="@Model.Money" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6">
                                @if (Model.DepositType == DepositType.收押金)
                                {
                                <label class="control-label col-md-3">收款账户：</label>
                                }
                                else
                                {
                                <label class="control-label col-md-3">付款账户：</label>
                                }

                                <div class="input-group">
                                    <input type="text" name="AccountName" class="input-sm form-control" value="@Model.AccountName" readonly="readonly">
                                </div>
                            </div>

                            <div class="col-md-6">
                                <label class="control-label col-md-3">经办人：</label>
                                <div class="input-group">
                                    <input type="text" name="AgentPeoper" class="input-sm form-control" value="@Model.AgentPeoper" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">备注：</label>
                                <div class="input-group">
                                    <textarea class="form-control" style="width:500px" readonly="readonly">@Model.RemarkContent</textarea>
                                </div>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="modal_ajax" class="modal inmodal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
</div>
@section scripts{
<script src="~/Theme/js/content.min.js?v=1.0.0"></script>
<script src="~/Theme/js/plugins/iCheck/icheck.min.js"></script>
<script src="~/Theme/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="~/Theme/js/plugins/suggest/bootstrap-suggest2014.js"></script>
<script src="~/js/DateComm.js"></script>
<script>
    $(document).ready(function () {
        $('#modal_ajax').on('show.bs.modal', function (e) {
            $(this).addClass('loading');
            var $button = $(e.relatedTarget);
            var url = $button.data('url');
            if (!!url) {
                url = url + ((url.indexOf("?") > -1) ? "&r=" : "?r=") + Math.random();
                $(this).load(url, function () {
                    $.validator.unobtrusive.parse(this); //$("#form_model_create").validate();
                    $("input[name='Member.Birthday']").datepicker({ todayBtn: "linked", keyboardNavigation: !1, forceParse: !1, calendarWeeks: !0, autoclose: !0 });
                    $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });


                    $.getJSON("/Deposit/GetRestaurantData").done(function (data) {
                        CommonAjaxCallback(data, function () {
                            bindSuggest(data.result);
                        }, null);
                    }).fail(function () {
                        layer.msg('连接超时，获取餐厅失败！', {
                            icon: 2,
                            time: 2000
                        });
                    });
                    $.getJSON("/Deposit/GetSettlementAccount").done(function (data) {
                        CommonAjaxCallback(data, function () {
                            bindSuggest1(data.result);
                        }, null);
                    }).fail(function () {
                        layer.msg('连接超时，获取账户失败！', {
                            icon: 2,
                            time: 2000
                        });
                    });

                    $.getJSON("/Deposit/GetAgentPeoperData").done(function (data) {
                        CommonAjaxCallback(data, function () {
                            bindSuggest2(data.result);
                        }, null);
                    }).fail(function () {
                        layer.msg('连接超时，获取经办人失败！', {
                            icon: 2,
                            time: 2000
                        });
                    });

                    $(this).removeClass('loading');

                    $('#date').datepicker({
                        todayBtn: "linked",
                        autoclose: true,
                        todayHighlight: true

                    });
                });
            }
        });
        $('#modal_ajax').on('hidden.bs.modal', function (e) {
            $(this).empty();
        });

    });

    function setCollectMoney(obj) {
        var ModifiableAmount = parseFloat($("#ModifiableAmount").val());
        var CollectMoney = parseFloat($("#CollectMoney").val());
        if (CollectMoney < ModifiableAmount) {
            layer.msg('押金收取金额不能小于【' + ModifiableAmount + '】！', {
                icon: 2,
                time: 2000
            });
            $("#CollectMoney").val(ModifiableAmount);
        }
    }

    function setReturnMoney(obj) {
        var ModifiableAmount = parseFloat($("#ModifiableAmount").val());
        var ReturnMoney = parseFloat($("#ReturnMoney").val());
        if (ReturnMoney > ModifiableAmount) {
            layer.msg('押金退还金额不能大于【' + ModifiableAmount + '】！', {
                icon: 2,
                time: 2000
            });
            $("#ReturnMoney").val(ModifiableAmount);
        }
    }

    function bindSuggest(data) {
        if ($("#dropdown-restaurantid") != undefined) {
            $role = $("#dropdown-restaurantid").bsSuggest({
                effectiveFields: ["restaurantName"],
                effectiveFieldsAlias: { "restaurantName": "餐厅" },
                searchFields: ["restaurantName"],
                clearable: true,
                getDataMethod: "data",
                //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                data: { value: data },
                idField: "id",
                keyField: "restaurantName",
            }).on('onDataRequestSuccess', function (e, result) {
                console.log('onDataRequestSuccess: ', result);
            }).on('onSetSelectValue', function (e, keyword, data) {
                $("#RestaurantId").val(data.id);
                console.log('onSetSelectValue: ', keyword, data);
            }).on('onUnsetSelectValue', function () {
                console.log('onUnsetSelectValue');
            });
        }
    }
    function blurEmpty() {
        var cityObj = $("#dropdown-restaurantid");
        var DriverId = $("#RestaurantId");
        if (cityObj.val() == "") {
            DriverId.attr("value", "");
        }
    }

    function bindSuggest1(data) {
        if ($("#dropdown-capitalaccountid") != undefined) {
            $role = $("#dropdown-capitalaccountid").bsSuggest({
                effectiveFields: ["name"],
                effectiveFieldsAlias: { "name": "餐厅" },
                searchFields: ["name"],
                clearable: true,
                getDataMethod: "data",
                //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                data: { value: data },
                idField: "id",
                keyField: "name",
            }).on('onDataRequestSuccess', function (e, result) {
                console.log('onDataRequestSuccess: ', result);
            }).on('onSetSelectValue', function (e, keyword, data) {
                $("#CapitalAccountId").val(data.id);
                console.log('onSetSelectValue: ', keyword, data);
            }).on('onUnsetSelectValue', function () {
                console.log('onUnsetSelectValue');
            });
        }
    }
    function blurEmpty1() {
        var cityObj = $("#dropdown-capitalaccountid");
        var DriverId = $("#CapitalAccountId");
        if (cityObj.val() == "") {
            DriverId.attr("value", "");
        }
    }

    function bindSuggest2(data) {
        if ($("#dropdown-agentpeoperuserid") != undefined) {
            $role = $("#dropdown-agentpeoperuserid").bsSuggest({
                effectiveFields: ["name"],
                effectiveFieldsAlias: { "name": "姓名" },
                searchFields: ["name"],
                clearable: true,
                getDataMethod: "data",
                //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                data: { value: data },
                idField: "id",
                keyField: "name",
            }).on('onDataRequestSuccess', function (e, result) {
                console.log('onDataRequestSuccess: ', result);
            }).on('onSetSelectValue', function (e, keyword, data) {
                $("#AgentPeoperUserId").val(data.id);
                console.log('onSetSelectValue: ', keyword, data);
            }).on('onUnsetSelectValue', function () {
                console.log('onUnsetSelectValue');
            });
        }
    }
    function blurEmpty2() {
        var cityObj = $("#dropdown-agentpeoperuserid");
        var DriverId = $("#AgentPeoperUserId");
        if (cityObj.val() == "") {
            DriverId.attr("value", "");
        }
    }

    function ReloadAjaxCallbackgoback(data, successInfo) {
        CommonAjaxCallback(data, function () {
            window.location.reload();
        }, successInfo);
    }
</script>
}